<?php

namespace common\config;


use yii\base\StaticInstanceInterface;
use yii\base\StaticInstanceTrait;

class Env implements StaticInstanceInterface
{
    use StaticInstanceTrait;

    public static $version = '';
    public static $domain = '';
    public static $quene_job_lock_key = 'quene_job_lock_key';
    public static $cookievalidationkey_home_and_admin = '';
    public static $demi_backup_folder = '@data/backup/demi';
    public static $home_suffix = '.html';
    public static $yii2appid_home = 'app-home';
    public static $yii2appid_admin = 'app-admin';
    public static $yii2appid_appapi = 'app-appapi';
    public static $yii2appid_webapi = 'app-webapi';
    public static $yii2appid_wechatapi = 'app-wechatapi';
    public static $yii2appid_console = 'app-console';

    public static $yii2app_console_login_name = '';
    public static $yii2app_console_login_password = '';

    public static $yiichina_login_name = '';
    public static $yiichina_login_password = '';

    /**
     * @return array
     */
    public static function getUrls()
    {
        $r = [
            'home_url' => '',
            'appapi_url' => '',
            'webapi_url' => '',
            'wechatapi_url' => '',
            'admin_url' => '',
        ];
        $domain = self::$domain;
        if (YII_ENV=='dev'){
            $r['home_url'] = "http://{$domain}/index-dev.php";
            $r['appapi_url'] = "http://{$domain}/appapi/index-dev.php";
            $r['webapi_url'] = "http://{$domain}/webapi/index-dev.php";
            $r['wechatapi_url'] = "http://{$domain}/wechatapi/index-dev.php";
            $r['admin_url'] = "http://{$domain}/admin/index-dev.php";
        }
        if (YII_ENV=='prod'){
            $r['home_url'] = "http://{$domain}";
            $r['appapi_url'] = "http://{$domain}/appapi";
            $r['webapi_url'] = "http://{$domain}/webapi";
            $r['wechatapi_url'] = "http://{$domain}/wechatapi";
            $r['admin_url'] = "http://{$domain}/admin";
        }
        return $r;
    }

    public static function getSwooleWebsocketConf()
    {
        return [
            'ip' => '0.0.0.0',
            'port' => '9502',
        ];
    }
}